/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package fr.ove.openmath.mathematica;

/**
 *
 * @author Mr.Sam
 */
import javax.swing.*;
import java.awt.*;
import fr.ove.openmath.mfd2.OneColumnLayout;

/**
* The work sheet.
*/
public class WorkSheet extends JPanel {
    private JPanel mainPanel;
    
    /**
    * The default constructor.<BR>
    * Constructs a <CODE>WorkSheet</CODE> with a width and height of 100
    */
	public WorkSheet() {
	    this(100, 100);
	}
	
	/**
	* The constructor.
	* @param width the width of the instance
	* @param height the height of the instance
	*/
	public WorkSheet(int width, int height) {
	    super();
	    setSize(width, height);
	    setLayout(new BorderLayout(0,0));
	    
		mainPanel = new JPanel();
		mainPanel.setLayout(new OneColumnLayout());
		
	    JScrollPane scrollPane = new JScrollPane(mainPanel);
	    scrollPane.setBackground(Color.white);
	    super.add(scrollPane);
	}
	
	/**
	* Adds a component to the instance.
	* @param comp the component to add
	*/
    public Component add(Component comp) {
	    return mainPanel.add(comp);
	}
	
	/**
	* Adds a component to the instance at the specified index.
	* @param comp the component to add.
	* @param index the specified index.
	*/
    public Component add(Component comp, int index) {
	    return mainPanel.add(comp, index);
	}
	
	/**
	* Removes the specified component from the instance.
	* @param comp the component to remove
	*/
	public void remove(Component comp) {
	    mainPanel.remove(comp);
	}
	
	/**
	* Removes the component at the specified index from the instance.
	* @param index the index of the component to remove
	*/
	public void remove(int index) {
	    mainPanel.remove(index);
	}
	
	/**
	* Removes all the components from the instance
	*/
	public void removeAll() {
	    mainPanel.removeAll();
	}
	
	/**
	* Returns all the components in the instance
	*/
	public Component[] getAll() {
	    return mainPanel.getComponents();
	}
}
